# -*- coding: utf-8 -*-

settings_config = {
    "USA": {
        "instrumentType": "EQUITY",
        "region": "USA",
        "universe": "TOP3000",
        "delay": 1,
        "decay": 6,
        "neutralization": "SUBINDUSTRY",
        "truncation": 0.08,
        "pasteurization": "ON",
        "testPeriod": "P2Y",
        "unitHandling": "VERIFY",
        "nanHandling": "ON",
        "language": "FASTEXPR",
        "visualization": False,
    },
    "ASI": {
        "instrumentType": "EQUITY",
        "region": "ASI",
        "universe": "MINVOL1M",
        "delay": 1,
        "decay": 6,
        "neutralization": "SUBINDUSTRY",
        "truncation": 0.08,
        "pasteurization": "ON",
        "testPeriod": "P2Y",
        "unitHandling": "VERIFY",
        "nanHandling": "ON",
        "language": "FASTEXPR",
        "visualization": False,
        "maxTrade": "ON",
    },
    "EUR": {
        "instrumentType": "EQUITY",
        "region": "EUR",
        "universe": "TOP2500",
        "delay": 1,
        "decay": 6,
        "neutralization": "SUBINDUSTRY",
        "truncation": 0.08,
        "pasteurization": "ON",
        "testPeriod": "P2Y",
        "unitHandling": "VERIFY",
        "nanHandling": "ON",
        "language": "FASTEXPR",
        "visualization": False
    },
    "CHN": {
        "instrumentType": "EQUITY",
        "region": "CHN",
        "universe": "TOP2000U",
        "delay": 1,
        "decay": 6,
        "neutralization": "SUBINDUSTRY",
        "truncation": 0.08,
        "pasteurization": "ON",
        "testPeriod": "P2Y",
        "unitHandling": "VERIFY",
        "nanHandling": "ON",
        "language": "FASTEXPR",
        "visualization": False
    },
    "GLB": {
        "instrumentType": "EQUITY",
        "region": "GLB",
        "universe": "MINVOL1M",
        "delay": 1,
        "decay": 6,
        "neutralization": "SUBINDUSTRY",
        "truncation": 0.08,
        "pasteurization": "ON",
        "testPeriod": "P2Y",
        "unitHandling": "VERIFY",
        "nanHandling": "ON",
        "language": "FASTEXPR",
        "visualization": False
    },
}

def get_all_settings():
    return [
        f"{idx+1}: {name} ({config['universe']})"
        for idx, (name, config) in enumerate(settings_config.items())
    ]

def get_by_index(index):
    """通过索引获取数据集名称"""

    try:
        return list(settings_config.values())[int(index)-1]
    except (IndexError, ValueError):
        return None